package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgAutoReply;
import edu.wpi.cs509.network.Connection;
import edu.wpi.cs509.serverlogic.Server;

/**
 * The base class for client->server messages.
 * 
 * @author mreiter
 */
public abstract class MsgServerContext extends MsgAutoReply {
	/**
	 * The serialization version ID.
	 */
	private static final long serialVersionUID = 1L;
	
	/** The server associated with the message. */
	private Server server;
	
	/**
	 * Used by the networking layer to set the connection after 
	 * the message has arrived.
	 * 
	 * @param connection The connection on which the message arrived.
	 */
	@Override
	public void setConnection(Connection connection) {
		super.setConnection(connection);
		
		server = (Server)connection.getOwner();
	}
	
	/**
	 * @return The server associated with the message.
	 */
	public Server getServer() {
		return server;
	}
}
